home *** CD-ROM | disk | FTP | other *** search
/ Super Shareware Collection / Super Shareware Collection.iso / os_2 / pm22x333.zip / GSP669.ASM < prev    next >
Assembly Source File  |  1994-02-21  |  9KB  |  283 lines

  1. ; Simple 669 playback routine using 'gs' lowlevel GUS routines.
  2. ; Doesn't do commands, only tempos perfectly.
  3.  
  4.         .386p
  5. code32  segment para public use32
  6.         assume cs:code32, ds:code32
  7.  
  8. include pmode.inc
  9. include gs.inc
  10.  
  11. public  _muzloc, _muzend, _muzrow, _muzord, _muzloop, _muzeord
  12.  
  13. public  _gsp669_init, _gsp669_uninit, _gsp669_load, _gsp669_play, _gsp669_stop
  14.  
  15. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  16. ; DATA
  17. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  18. align 4
  19. ordptr          dd      ?               ; ptr to order list
  20. tempoptr        dd      ?               ; ptr to tempo list
  21. breakptr        dd      ?               ; ptr to break list
  22. patbaseptr      dd      ?               ; ptr to base of patterns
  23. instptr         dd      ?               ; ptr to sample data
  24.  
  25. currowptr       dd      ?               ; ptr to next row to play
  26.  
  27. _muzloc         label   word            ; ord:row                            |
  28. _muzrow         db      ?               ; current row playing                |
  29. _muzord         db      ?               ; current order playing              |
  30. _muzend         label   word            ; end:loop                          |
  31. _muzloop        db      ?               ; loop point of 669                 |
  32. _muzeord        db      ?               ; last+1 order of 669               |
  33.  
  34. panloc          db      0               ; base of ping-pong pan
  35. tempo           db      ?               ; tempo
  36. tempoc          db      ?               ; tempo counter                      |
  37. row             db      ?               ; current row                        |
  38. ord             db      ?               ; current order                      |
  39. break           db      ?               ; row of break                       |
  40.  
  41. pantbl          db      3,3,3,4,4,5,6,7,8,9,10,11,11,12,12,12
  42.                 db      12,12,12,11,11,10,9,8,7,6,5,4,4,3,3,3
  43.                 db      3,3,3,4,4,5,6,7,8,9,10,11,11,12,12,12
  44.                 db      12,12,12,11,11,10,9,8,7,6,5,4,4,3,3,3
  45.                 db      3,3,3,4,4,5,6,7,8,9,10,11,11,12,12,12
  46.                 db      12,12,12,11,11,10,9,8,7,6,5,4,4,3,3,3
  47.                 db      3,3,3,4,4,5,6,7,8,9,10,11,11,12,12,12
  48.                 db      12,12,12,11,11,10,9,8,7,6,5,4
  49.  
  50. voltbl          db      004h,0a0h,0b0h,0c0h,0c8h,0d0h,0d8h,0e0h
  51.                 db      0e4h,0e8h,0ech,0f0h,0f2h,0f4h,0f6h,0f8h
  52.  
  53. freqtbl         dw      56,59,62,66,70,74,79,83,88,94,99,105
  54.                 dw      112,118,125,133,141,149,158,167,177,188,199,211
  55.                 dw      224,237,251,266,282,299,317,335,355,377,399,423
  56.                 dw      448,475,503,532,564,598,634,671,711,754,798,846
  57.                 dw      896,950,1006,1065,1129,1197,1268,1343,1423,1508,1597,1692
  58.  
  59. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  60. ; CODE
  61. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  62.  
  63. ;═════════════════════════════════════════════════════════════════════════════
  64. ; Main playback routine called by GUS IRQ routine
  65. mr:
  66.         mov al,tempoc
  67.         dec al
  68.         jnz mrd
  69.  
  70.         mov esi,currowptr
  71.         mov ax,word ptr row
  72.         inc al
  73.         cmp al,break
  74.         jbe short mrf0
  75.         xor al,al
  76.         inc ah
  77.         cmp ah,_muzeord
  78.         jbe short mrf1
  79.         mov ah,_muzloop
  80. mrf1:
  81.         movzx ebp,ah
  82.         mov edi,ordptr
  83.         movzx esi,byte ptr ds:[ebp+edi]
  84.         mov edi,tempoptr
  85.         mov bl,[edi+esi]
  86.         mov tempo,bl
  87.         mov edi,breakptr
  88.         mov bl,[edi+esi]
  89.         mov break,bl
  90.         lea esi,[esi*2+esi]
  91.         shl esi,9
  92.         add esi,patbaseptr
  93. mrf0:
  94.         mov word ptr row,ax
  95.         mov _muzloc,ax
  96.  
  97.         movzx edx,panloc
  98.         inc dl
  99.         and dl,3fh
  100.         mov panloc,dl
  101.         mov edi,instptr
  102.         mov ebp,7
  103. mrl0:
  104.         mov al,[esi+2]
  105.         mov ah,al
  106.         and al,0f0h
  107.         cmp al,50h
  108.         jne short mrl0f0
  109.         and ah,0fh
  110.         mov tempo,ah
  111. mrl0f0:
  112.         mov bl,pantbl[edx+ebp*4]
  113.         mov _vcpan[ebp],bl
  114.         or _vccmnd[ebp],2
  115.         mov ax,[esi]
  116.         cmp al,0feh
  117.         ja mrl0c
  118.         movzx ebx,ah
  119.         and bl,0fh
  120.         mov bl,voltbl[ebx]
  121.         mov _vcvol[ebp],bl
  122.         or _vccmnd[ebp],1
  123.         cmp al,0feh
  124.         je short mrl0c
  125.         xchg al,ah
  126.         shr ax,2
  127.         shr al,2
  128.         movzx ebx,ah
  129.         mov cx,freqtbl[ebx*2]
  130.         mov _vcfreq[ebp*2],cx
  131.         movzx ebx,al
  132.         lea ebx,[ebx*4+ebx]
  133.         lea ebx,[ebx*4+ebx]
  134.         mov al,[edi+ebx+12]
  135.         mov _vccntrl[ebp],al
  136.         mov eax,[edi+ebx+13]
  137.         mov _vcsbeg[ebp*4],eax
  138.         mov eax,[edi+ebx+17]
  139.         mov _vclbeg[ebp*4],eax
  140.         mov eax,[edi+ebx+21]
  141.         mov _vclend[ebp*4],eax
  142.         mov _vccmnd[ebp],8
  143. mrl0c:
  144.         add esi,3
  145.         sub ebp,1
  146.         jnc mrl0
  147.  
  148.         mov currowptr,esi
  149.         mov al,tempo
  150. mrd:
  151.         mov tempoc,al
  152.         ret
  153.  
  154. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  155. ; Init 669 player and low level gus crap
  156. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  157. _gsp669_init:
  158.         mov _gustimerfreq,9ch
  159.         mov _gusnumvoices,0cfh
  160.         call _gs_init
  161.         ret
  162.  
  163. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  164. ; Reset 669 player and low level gus crap
  165. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  166. _gsp669_uninit:
  167.         call _gsp669_stop
  168.         call _gs_uninit
  169.         ret
  170.  
  171. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  172. ; Load a 669, samples go directly into GUS ram
  173. ; In:
  174. ;   EAX -> stream input routine (In:ECX=len,EDX->buf, Out:EAX=len,CF=1 error)
  175. ;   EDX -> buffer large enough for all music data plus largest sample
  176. ; Out:
  177. ;   EAX - number of bytes of buffer to keep
  178. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  179. _gsp669_load:
  180.         pushad
  181.         mov ebp,edx
  182.         mov ecx,1f1h
  183.         call eax
  184.         mov al,[edx+70h]
  185.         mov _muzloop,al
  186.         lea eax,[edx+71h]
  187.         mov ordptr,eax
  188.         add eax,80h
  189.         mov tempoptr,eax
  190.         add eax,80h
  191.         mov breakptr,eax
  192.         add edx,ecx
  193.         mov instptr,edx
  194.         lea esi,[edx+13]
  195.         movzx edi,byte ptr [ebp+6eh]
  196.         imul ecx,edi,25
  197.         call dword ptr [esp+28]
  198.         add edx,ecx
  199.         mov patbaseptr,edx
  200.         movzx ecx,byte ptr [ebp+6fh]
  201.         lea ecx,[ecx*2+ecx]
  202.         shl ecx,9
  203.         call dword ptr [esp+28]
  204.         add edx,ecx
  205.         xor ebx,ebx
  206. gsp669loadl0:
  207.         mov ecx,[esi]
  208.         add esi,25
  209.         jecxz gsp669loadl0c
  210.         call dword ptr [esp+28]
  211.         push ecx
  212. gsp669loadl2:
  213.         xor byte ptr [edx],80h
  214.         inc edx
  215.         loop gsp669loadl2
  216.         pop ecx
  217.         sub edx,ecx
  218.         call _gs_putram
  219.         add ebx,ecx
  220. gsp669loadl0c:
  221.         dec edi
  222.         jnz gsp669loadl0
  223.         sub edx,[esp+20]
  224.         mov [esp+28],edx
  225.  
  226.         mov esi,instptr
  227.         movzx ecx,byte ptr [ebp+6eh]
  228.         xor ebx,ebx
  229. gsp669loadl1:
  230.         mov edx,[esi+13]
  231.         mov [esi+13],ebx
  232.         mov al,8
  233.         cmp edx,[esi+21]
  234.         jae short gsp669loadl1c
  235.         xor al,al
  236.         mov [esi+21],edx
  237. gsp669loadl1c:
  238.         add [esi+17],ebx
  239.         add [esi+21],ebx
  240.         dec dword ptr [esi+21]
  241.         mov [esi+12],al
  242.         add ebx,edx
  243.         add esi,25
  244.         loop gsp669loadl1
  245.  
  246.         popad
  247.         ret
  248.  
  249. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  250. ; Play a loaded 669
  251. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  252. _gsp669_play:
  253.         push ax ecx edi
  254.         call _gsp669_stop
  255.         mov edi,ordptr
  256.         mov ecx,80h
  257.         mov al,0ffh
  258.         repne scasb
  259.         sub cl,7eh
  260.         neg cl
  261.         mov _muzeord,cl
  262.         mov _muzloc,0
  263.         mov panloc,0
  264.         mov dword ptr tempoc,0ff0001h
  265.         mov _gusrout,offset mr
  266.         pop edi ecx ax
  267.         ret
  268.  
  269. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  270. ; Stop playback
  271. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  272. _gsp669_stop:
  273.         mov _gusrout,offset _ret
  274.         mov dword ptr _vcvol[0],4040404h
  275.         mov dword ptr _vcvol[4],4040404h
  276.         mov dword ptr _vccmnd[0],1010101h
  277.         mov dword ptr _vccmnd[4],1010101h
  278.         ret
  279.  
  280. code32  ends
  281.         end
  282.  
  283.